import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        // appBar: AppBar(
        //   title: Text('Flutter Example'),
        // ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverAppBar(
          // 去掉标题
          // title: Text('标题'),
          expandedHeight: 230.0,
          floating: false,
          pinned: true,
          snap: false,
          leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              print("返回");
            },
          ),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.add),
              onPressed: () {
                print("添加");
              },
            ),
            IconButton(
              icon: Icon(Icons.more_horiz),
              onPressed: () {
                print("更多");
              },
            )
          ],
          flexibleSpace: FlexibleSpaceBar(
            title: Text('标题标题'),
            centerTitle: false,
            collapseMode: CollapseMode.pin,
          ),
        ),
        SliverFixedExtentList(
          itemExtent: 50.0,
          delegate: SliverChildBuilderDelegate(
              (context, index) => ListTile(
                    title: Text('Item $index'),
                  ),
              childCount: 30),
        )
      ],
    );
  }
}
